ALMaSS  1.0
The Animal, Landscape and Man Simulation System
AOR_Probe Class Reference

#include <AOR_Probe.h>

Inheritance diagram for AOR_Probe:
AOR_Probe_Goose

Public Member Functions

 AOR_Probe (Population_Manager *a_owner, Landscape *a_TheLandscape, string a_filename)
 
virtual ~AOR_Probe ()
 
virtual void CloseFile ()
 
void WriteData ()
 
virtual void DoProbe (int a_lifestage)
 

Protected Attributes

ofstream m_ProbeFile
 
int m_gridcountwidth [4]
 
int m_gridcountheight [4]
 
int m_gridcountsize [4]
 
int m_totalcells [4]
 
ListOfCells m_gridcount [4]
 
Landscapem_TheLandscape
 
Population_Managerm_owner
 

Constructor & Destructor Documentation

◆ AOR_Probe()

AOR_Probe::AOR_Probe ( Population_Manager a_owner,
Landscape a_TheLandscape,
string  a_filename 
)
12 {
13  m_owner = a_owner;
14  m_TheLandscape = a_TheLandscape;
15  if (a_filename == "") a_filename = "NWordOutputPrb.txt"; // this is for backwards compatability - this output used to be called NWord
16  m_ProbeFile.open(a_filename, ios::out);
17  if (!m_ProbeFile) {
18  g_msg->Warn(WARN_FILE, "Population_Manager::AOR_Probe: ""Unable to open NWord probe file", "");
19  exit(1);
20  }
21  m_ProbeFile << "Year" << '\t' << "Day" << '\t' << "Total_no" << '\t' << "Cells50" << '\t' << "Occupied50" << '\t' << "Cells100" << '\t' << "Occupied100" << '\t' << "Cells200" << '\t' << "Occupied200" << '\t' << "Cells400" << '\t' << "Occupied400" << endl;
22  m_gridcountsize[0] = 50;
23  m_gridcountsize[1] = 100;
24  m_gridcountsize[2] = 200;
25  m_gridcountsize[3] = 400;
26  for (int g = 0; g < 4; g++) {
30  m_gridcount[g].resize(m_totalcells[g]);
31  }
32 }
Landscape * m_TheLandscape
Definition: AOR_Probe.h:15
Population_Manager * m_owner
Definition: AOR_Probe.h:16
int m_gridcountsize[4]
Definition: AOR_Probe.h:11
int m_gridcountwidth[4]
Definition: AOR_Probe.h:9
ofstream m_ProbeFile
Definition: AOR_Probe.h:8
ListOfCells m_gridcount[4]
Definition: AOR_Probe.h:13
int m_gridcountheight[4]
Definition: AOR_Probe.h:10
int m_totalcells[4]
Definition: AOR_Probe.h:12
int SupplySimAreaHeight(void)
Definition: landscape.h:1637
int SupplySimAreaWidth(void)
Definition: landscape.h:1632
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:59
class MapErrorMsg * g_msg
This pointer provides access the to the internal ALMaSS error message system.
Definition: maperrormsg.cpp:41
@ WARN_FILE
Definition: maperrormsg.h:37

References g_msg, MapErrorMsg::Warn(), and WARN_FILE.

◆ ~AOR_Probe()

virtual AOR_Probe::~AOR_Probe ( )
inlinevirtual
19  {
20  CloseFile();
21  }
virtual void CloseFile()
Definition: AOR_Probe.h:23

References CloseFile().

Member Function Documentation

◆ CloseFile()

virtual void AOR_Probe::CloseFile ( )
inlinevirtual
23  {
24  m_ProbeFile.close();
25  }

References m_ProbeFile.

Referenced by ~AOR_Probe().

◆ DoProbe()

void AOR_Probe::DoProbe ( int  a_lifestage)
virtual

Counts all a_lifestage animals in each grid of each size

Reimplemented in AOR_Probe_Goose.

59  {
61  unsigned int total = (unsigned)m_owner->GetLiveArraySize(a_lifestage);
62  // Empty old data
63  for (int grid = 0; grid < 4; grid++) {
64  for (int i = 0; i < m_totalcells[grid]; i++) m_gridcount[grid][i] = 0;
65  }
66  // For each animal get the location and place it in each of the (4) grids
67  for (unsigned j = 0; j < total; j++) //adult females
68  {
69  APoint pt = m_owner->SupplyAnimalPtr(a_lifestage, j)->SupplyPoint();
70  for (int grid = 0; grid < 4; grid++) {
71  int gx = pt.m_x / m_gridcountsize[grid];
72  int gy = pt.m_y / m_gridcountsize[grid];
73  m_gridcount[grid][gx + gy*m_gridcountwidth[grid]]++;
74  }
75  }
76  WriteData();
77 }
void WriteData()
Definition: AOR_Probe.cpp:35
A simple class defining an x,y coordinate set.
Definition: ALMaSS_Setup.h:53
int m_y
Definition: ALMaSS_Setup.h:56
int m_x
Definition: ALMaSS_Setup.h:55
TAnimal * SupplyAnimalPtr(int a_index, int a_animal)
Returns the pointer indexed by a_index and a_animal. Note NO RANGE CHECK.
Definition: PopulationManager.h:465
unsigned GetLiveArraySize(int a_listindex)
Gets the number of 'live' objects for a list index in the TheArray.
Definition: PopulationManager.h:433
APoint SupplyPoint()
Definition: PopulationManager.h:209

References APoint::m_x, and APoint::m_y.

Referenced by Bembidion_Population_Manager::TheAOROutputProbe(), THare_Population_Manager::TheAOROutputProbe(), Newt_Population_Manager::TheAOROutputProbe(), Partridge_Population_Manager::TheAOROutputProbe(), Rabbit_Population_Manager::TheAOROutputProbe(), RoeDeer_Population_Manager::TheAOROutputProbe(), Skylark_Population_Manager::TheAOROutputProbe(), and Vole_Population_Manager::TheAOROutputProbe().

◆ WriteData()

void AOR_Probe::WriteData ( )

A common output stub for the AOR output probe. Specialist counting for each species occurs as part of the AOR grid probe, then this method deals with the final output.

36 {
39  int Counted[4];
40  int OccupiedCells[4];
41  for (int gsz = 0; gsz < 4; gsz++) {
42  Counted[gsz] = 0;
43  OccupiedCells[gsz] = 0;
44  for (int i = 0; i < m_gridcountwidth[gsz]; i++) {
45  for (int j = 0; j < m_gridcountheight[gsz]; j++) {
46  int res = m_gridcount[gsz][i + j*m_gridcountwidth[gsz]];
47  Counted[gsz] += res;
48  if (res > 0) OccupiedCells[gsz]++;
49  }
50  }
51  }
52  m_ProbeFile << m_TheLandscape->SupplyYearNumber() << '\t' << (int)m_TheLandscape->SupplyDayInYear() << '\t' << Counted[0] << '\t';
53  for (int c = 0; c < 3; c++) {
54  m_ProbeFile << m_totalcells[c] << '\t' << OccupiedCells[c] << '\t';
55  }
56  m_ProbeFile << m_totalcells[3] << '\t' << OccupiedCells[3] << endl;
57 }
int SupplyYearNumber(void)
Definition: landscape.h:1616
int SupplyDayInYear(void)
Definition: landscape.h:1596

Referenced by AOR_Probe_Goose::DoProbe().

Member Data Documentation

◆ m_gridcount

ListOfCells AOR_Probe::m_gridcount[4]
protected

◆ m_gridcountheight

int AOR_Probe::m_gridcountheight[4]
protected

◆ m_gridcountsize

int AOR_Probe::m_gridcountsize[4]
protected

◆ m_gridcountwidth

int AOR_Probe::m_gridcountwidth[4]
protected

◆ m_owner

Population_Manager* AOR_Probe::m_owner
protected

◆ m_ProbeFile

ofstream AOR_Probe::m_ProbeFile
protected

Referenced by CloseFile().

◆ m_TheLandscape

Landscape* AOR_Probe::m_TheLandscape
protected

◆ m_totalcells

int AOR_Probe::m_totalcells[4]
protected

The documentation for this class was generated from the following files: